<?php
session_start();
require_once 'header.php';
function __autoload($className)
	{
    	require_once('class/' . $className . '.class.php');
	}
session::need_manage();
$MonthNow=date("m");
if(!empty($_GET["plusmoney"]))
{
	$Month=intval($_GET["month"]);
	$Year=intval($_GET["year"]);
	if(strlen($Month)==1)
	{
		$Month="0".$Month;
	}
	$date=$Year."-".$Month;
	$Amount="50";
	$condition[] = "date like '%".mysql_escape_string($date)."%'";
	$condition[]="payment.userid=userinfo.userid";
	$GetTop=database::LimitQuery('payment,userinfo',array(
	'select' => 'payment.userid,sum(amount),username',
	'condition' => $condition,
	'groupby' => 'group by payment.userid',
	'offset' => 0,
	'size' => 1,
	'order' => 'order by sum(amount) desc'
	));
	$Userid=$GetTop[0]['userid'];
	$UserName=$GetTop[0]['username'];
	$password=md5($_POST["password"]);
	if($password=='30dc72025357a119f014c052c8b8c68c')
	{
		$Plus=database::Update('userinfo',array('userid'=>$Userid),array('money' => array( "money + {$Amount}")));
		if($Plus==true)
		{
			echo "The money has been plus to $UserName";
		}
	}
	else 
	{
		echo "invalid Password";
	}
}
else
{
	require_once 'html/plusmoney.php';	
}
?>